package com.chenyuxin.ilp.controller.file;

import com.chenyuxin.ilp.model.dto.file.DeleteFileDto;
import com.chenyuxin.ilp.model.pojo.Result;
import com.chenyuxin.ilp.service.file.FileService;
import com.chenyuxin.ilp.service.file.RecycleBinService;
import com.chenyuxin.ilp.util.SecurityUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/file/recyclebin")
public class RecycleBinController {
    @Autowired
    private RecycleBinService recycleBinService;
    // 查询回收站文件
    @GetMapping("/recycle")
    public Result selectRecycleFile(){
        String userId = SecurityUtil.getUserId();
        return recycleBinService.selectRecycleFile(userId);
    }
    // 删除回收站文件
    @DeleteMapping("/{fileid}")
    public Result deleteRecycleFile(@PathVariable Long fileid){
        String userId = SecurityUtil.getUserId();
        return recycleBinService.deleteRecycleFile(userId,fileid);
    }
    // 清空回收站文件
    @DeleteMapping("/empty")
    public Result emptyRecycleBin(){
        String userId = SecurityUtil.getUserId();
        return recycleBinService.emptyRecycleBin(userId);
    }
    // 回收站文件找回
    @PostMapping("/retrieval/{fileid}")
    public Result retrievalRecycleFile(@PathVariable("fileid")String fileId){
        String userId = SecurityUtil.getUserId();
        return recycleBinService.retrievalRecycleFile(fileId,userId);
    }
}
